Accessing data from service locations and creating new service locations
A service location refers to a place in which BinBars are located. Service locations may contain many container sites.
A service location can be thought of as a geographical location. For example, a service location may refer to a factory or a town.
The specifics of how to name and organize service locations are up to you, but we recommend against broad service locations such as "East Coast" and "West Coast" as this will make specific data more difficult to query and organize
The primary purpose of service locations are as a reporting tool to better organize container sites
The container sites that belong to a service location are ones that are inside of that geographical location. Think of a service location as a logical grouping of container sites
For information on what can be queried refer to the service location documentation
How to create a new service location
1. Find your account's ID using the query currentUser
2. Create a new service location using the mutation createServiceLocation
- Query
- Result
query getAccountID {
currentUser {
account {
__typename
id
# Some 'Account' fields omitted for brevity
}
}
}
{
"data": {
"currentUser": {
"account": {
"__typename": "Account",
"id": "abc123foiuds8535235c"
}
}
}
}
- Query
- Result
mutation CreateServiceLocation($input: CreateServiceLocationInput!) {
createServiceLocation(input: $input) {
__typename
id
name
# Some 'serviceLocation' fields omitted for brevity
}
}
variables = {input: { name: 'My New Service Location', accountID: accountID }};
{
"data": {
"createServiceLocation": {
"__typename": "ServiceLocation",
"id": "235madflid2340c",
"name": "My New Service Location"
}
}
}
When creating new service locations, it may be useful to query for that ID at the same time so you do not have to query for it later
Find all service locations
Using the query currentUser
- Query
- Result
query currentUser {
currentUser {
account {
serviceLocations {
__typename
name
id
containerSites {
id
}
# Some 'serviceLocation' fields omitted for brevity
}
}
}
}
{
"data": {
"currentUser": {
"account": {
"serviceLocations": [
{
"__typename": "ServiceLocation",
"name": "Denver Road Location",
"id": "123abc8972354nf5234a",
"containerSites": [
{
"id": "123abc8972354254nlfc4a"
},
{
"id": "123abc8972354254nlfca35c"
}
]
},
{
"__typename": "ServiceLocation",
"name": "My New Service Location",
"id": "123abc8972354nf5ac85n",
"containerSites": []
}
]
}
}
}
}
Larger queries will take longer to retrieve. For larger queries, we recommend using the optional paginationInput. To learn more, visit Paginating Queries
With the above query you can also find one service location with a particular container site or find all service locations that do not have any container sites
How to find a service location's information with an ID
Using the query serviceLocationByID
- Query
- Result
query ServiceLocationByID($id: ID!) {
serviceLocationByID(id: $id) {
__typename
id
name
# Some 'serviceLocation' fields omitted for brevity
}
}
variables = { id: '123abc8972354nf5234a' };
{
"data": {
"serviceLocationByID": {
"__typename": "ServiceLocation",
"id": "123abc8972354nf5234a",
"name": "Denver Road Location"
}
}
}